package exam.day28;

import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Test1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int q = in.nextInt();
        while(q-- != 0) {
            int a = in.nextInt();
            int x = a;
            StringBuffer sb = new StringBuffer();
            while(x != 0) {
                sb.append(x % 10);
                x /= 10;
            }
            int n = sb.length();
            int k = -1;
            for(int i = 0; i < n; i++) {
                if(Integer.valueOf(sb.charAt(i) - '0') % 2 == 0) {
                    k = i;
                    break;
                }
            }
            if(k == -1) {
                System.out.println(-1);
            }else {
                int ret = 0;
                int j = 0;
                for(int i = 0; i < n; i++) {
                    if(i == k) {
                        continue;
                    }
                    ret += (Math.pow(10, j++ + 1) * Integer.valueOf(sb.charAt(i) - '0'));
                }
                ret +=  Integer.valueOf(sb.charAt(k) - '0');
                System.out.println(ret);
            }
        }
    }
}
